﻿using System.ComponentModel.DataAnnotations;
using FinancePortal.Domain.Model;

namespace FinancePortal.Web.Models
{
    public class ResourceViewModel
    {
        public int Id { get; set; }

        [Required]
        [StringLength(7, MinimumLength = 7)]
        public string SOEID { get; set; }

        [Required]
        [StringLength(50)]
        public virtual string Name { get; set; }

        [Required]
        [StringLength(100)]
        public string Email { get; set; }

        [Required]
        public int AreaId { get; set; }

        [Required]
        public int Profile { get; set; }

        public static Resource ToModel(ResourceViewModel view)
        {
            return new Resource
            {
                Id = view.Id,
                Name = view.Name,
                SOEID = view.SOEID,
                Email = view.Email,
                AreaId = view.AreaId,
                Profile = view.Profile
            };
        }
    }
}